<template>
  <div class="view-fill asset-card-details">
    <div
      v-if="
        !showModify.visible &&
        !replenishMaintenanceModify.visible &&
        !financeModifyInfo.visible &&
        !maintenanceOrderDetailInfo.visible &&
        !curingDetailInfo.visible && 
        !recodeDetailInfo.visible &&
        !taskDetailInfo.visible
      "
      class="app-container-flex"
    >
      <NewFullScreen
        v-model="showDialog"
        :btn-list="btnList"
        :title="title"
        :needOperateAffair="true"
        :operateAffairData="affairTableInfo"
        :needReturn="!$route.query.processInstanceId"
        @returnBack="returnBack"
      >
        <template v-slot:full-button>
          <el-button v-if="canUpdate" @click="update">修改</el-button>
          <PopoverPrint
            ref="popoverShow"
            v-model:popoverVisible="popoverVisible"
            :canPrint="canPrint"
            :templateArr="templateArr"
            @tempClick="tempClick"
            @print="print"
          ></PopoverPrint>
          <el-button v-if="canExcel" @click="exportExcel">导出excel</el-button>
          <el-button v-if="canSubmit" @click="submit">提交</el-button>
          <el-button v-if="canRevoke" @click="revoke">撤回</el-button>
          <el-button v-if="canRatify" @click="ratify">审核</el-button>
          <el-button v-if="canCancelAudit" @click="cancelAudit">销审</el-button>
          <el-button v-if="canReject" @click="reject">驳回</el-button>
          <el-button v-if="canRefuse" @click="refuse">拒绝</el-button>
          <el-button v-if="canSlpit" @click="_assetCardSplit"
            >资产拆分</el-button
          >
          <!-- <el-button v-if="canUpdateFinance" @click="updateFinance"
            >财务信息修改</el-button
          >
          <el-button v-if="canSubmitFinance" @click="submitFinance"
            >财务信息提交</el-button
          >
          <el-button
            v-if="canRegisterFinance"
            @click="registerFinancialInformation"
            >财务信息登记</el-button
          >
          <el-button v-if="canCancelFinance" @click="cancelFinancialInformation"
            >取消财务登记</el-button
          >
          <el-button v-if="canRatifyFinance" @click="ratifyFinance"
            >财务信息确认</el-button
          >
          <el-button v-if="canRejectFinance" @click="rejectFinance"
            >财务信息驳回</el-button
          >
          <el-button v-if="canRevokeFinance" @click="revokeFinance"
            >财务信息撤回</el-button
          > -->
          <el-button
            v-if="canReplenishMaintenance"
            @click="replenishMaintenance"
            >信息补录/修改</el-button
          >
          <!-- <el-button v-if="canFinanceAdjust" @click="financeAdjust"
            >财务信息调整</el-button
          > -->
          <el-button v-if="canCopyCreate" @click="copyCreate"
            >复制并新增</el-button
          >
          <el-button v-if="canPrintAsset" @click="printAssetCode()"
            >打印资产条码</el-button
          >
        </template>

        <div class="model-panel">
          <div class="model-panel-title">
            <p>{{ $t('basic_information') }}</p>
          </div>
          <div class="model-panel-body">
            <basic-information
              :info="baseInfoList"
              :image-field="baseInfoList.imageField"
            >
              <template v-slot:basic-assetCapitalSourceVOList>
                <page-table
                  v-if="
                    baseInfoList.data.assetCapitalSourceVOList &&
                    baseInfoList.data.assetCapitalSourceVOList.length
                  "
                  v-model:data="baseInfoList.data.assetCapitalSourceVOList"
                  :check-box="false"
                  :tab-index="true"
                  :pager="false"
                  :summary="true"
                  :summaryFieldList="
                    assetCapitalSourceTableInfo.summaryFieldList
                  "
                  :field-list="assetCapitalSourceTableInfo.fieldList"
                  :handle="assetCapitalSourceTableInfo.handle"
                >
                  <template v-slot:col-capitalProjectList="scope">
                    <template
                      v-if="
                        scope.row.capitalProjectList &&
                        scope.row.capitalProjectList.length
                      "
                    >
                      <span
                        v-for="(item, index) in scope.row.capitalProjectList"
                        :key="index"
                      >
                        {{ item.assetCapitalProjectName }}-{{
                          '(' + item.useAmount + ')'
                        }}<br />
                      </span>
                    </template>
                    <span v-else>-</span>
                  </template>
                </page-table>
                <span v-else>-</span>
              </template>
              <template v-slot:basic-assetUseDeptVOList>
                <div
                  style="width: 83%; margin-bottom: 10px"
                  v-if="
                    financeInfoList.data.assetUseDeptVOList &&
                    financeInfoList.data.assetUseDeptVOList.length
                  "
                >
                  <page-table
                    v-model:data="financeInfoList.data.assetUseDeptVOList"
                    :pager="false"
                    :check-box="false"
                    :tab-index="true"
                    :field-list="assetAmortizationDeptTableInfo.fieldList"
                  >
                  </page-table>
                </div>
                <span v-else>-</span>
              </template>
              <template v-slot:basic-associatedSubcard>
                <!-- //  组件/部件  关联子卡片 -->
                <associatedSubcard
                  class="associated-subcard"
                  :isEmpty="true"
                  :disabeld="true"
                  :assetResourceVOList="baseInfoList.data.assetResourceVOList"
                />
              </template>
            </basic-information>
          </div>
        </div>

        <div class="model-panel">
          <div class="model-panel-title">
            <p>{{ $t('common_information') }}</p>
          </div>
          <div class="model-panel-body">
            <basic-information :info="commonInfoList"></basic-information>
          </div>
        </div>
        <div class="model-panel" v-show="baseInfoList.data.isFinanceAsset">
          <div class="model-panel-title">
            <p>{{ $t('finance_information') }}</p>
          </div>
          <div class="model-panel-body">
            <basic-information :info="financeInfoList"> </basic-information>
          </div>
        </div>
        <div class="model-panel" v-show="baseInfoList.data.isMaintenance">
          <div class="model-panel-title">
            <p>{{ $t('maintenance_information') }}</p>
          </div>
          <div class="model-panel-body">
            <basic-information :info="maintenanceInfoList"></basic-information>
          </div>
        </div>
        <div class="model-panel" v-show="baseInfoList.data.isMetering">
          <div class="model-panel-title">
            <p>{{ $t('measurement_information') }}</p>
          </div>
          <div class="model-panel-body">
            <basic-information :info="measurementInfoList"></basic-information>
          </div>
        </div>

        <div class="model-panel">
          <div class="model-panel-body">
            <div class="flex_full_item">
              <el-tabs v-model="activeName" @tab-click="handleClick">
                <el-tab-pane
                  v-if="baseInfoList.data.isFinanceAsset"
                  class="model-panel-title"
                  label="折旧记录"
                  name="first"
                >
                  <!-- 表格 -->
                  <el-form
                    ref="tableForm"
                    :model="deprTableInfo"
                    style="width: 100%"
                  >
                    <page-table
                      :refresh="deprTableInfo.refresh"
                      :init-curpage="deprTableInfo.initCurpage"
                      v-model:data="deprTableInfo.data"
                      :pager="false"
                      :check-box="false"
                      :tab-index="true"
                      :api="deprTableInfo.api"
                      :query="deprTableInfo.query"
                      :field-list="deprTableInfo.fieldList"
                      :handle="deprTableInfo.handle"
                    />
                  </el-form>
                </el-tab-pane>
                <el-tab-pane
                  class="model-panel-title"
                  label="调整记录"
                  name="second"
                >
                  <!-- 表格 -->
                  <el-form
                    ref="tableForm"
                    :model="adjustTableInfo"
                    style="width: 100%"
                  >
                    <page-table
                      :refresh="adjustTableInfo.refresh"
                      :init-curpage="adjustTableInfo.initCurpage"
                      v-model:data="adjustTableInfo.data"
                      :pager="false"
                      :check-box="false"
                      :tab-index="true"
                      :api="adjustTableInfo.api"
                      :query="adjustTableInfo.query"
                      :field-list="adjustTableInfo.fieldList"
                      :handle="adjustTableInfo.handle"
                    />
                  </el-form>
                </el-tab-pane>
                <el-tab-pane
                  class="model-panel-title"
                  label="减少记录"
                  name="third"
                >
                  <!-- 表格 -->
                  <el-form
                    ref="tableForm"
                    :model="reduceTableInfo"
                    style="width: 100%"
                  >
                    <page-table
                      :refresh="reduceTableInfo.refresh"
                      :init-curpage="reduceTableInfo.initCurpage"
                      v-model:data="reduceTableInfo.data"
                      :pager="false"
                      :check-box="false"
                      :tab-index="true"
                      :api="reduceTableInfo.api"
                      :query="reduceTableInfo.query"
                      :field-list="reduceTableInfo.fieldList"
                      :handle="reduceTableInfo.handle"
                    />
                  </el-form>
                </el-tab-pane>

                <el-tab-pane
                  class="model-panel-title"
                  label="计量器具检定记录"
                  name="five"
                  v-if="$permission('assetInstrumentsPlan:history')"
                >
                  <!-- 表格 -->
                  <el-form
                    ref="tableForm"
                    :model="instrumentsRecordTableInfo"
                    style="width: 100%"
                  >
                    <page-table
                      :refresh="instrumentsRecordTableInfo.refresh"
                      :init-curpage="instrumentsRecordTableInfo.initCurpage"
                      v-model:data="instrumentsRecordTableInfo.data"
                      :pager="false"
                      :check-box="false"
                      :tab-index="true"
                      :api="instrumentsRecordTableInfo.api"
                      :query="instrumentsRecordFilterInfo.query"
                      :field-list="instrumentsRecordTableInfo.fieldList"
                      :handle="instrumentsRecordTableInfo.handle"
                    />
                  </el-form>
                </el-tab-pane>
                <el-tab-pane
                  class="model-panel-title"
                  label="维修记录"
                  name="sixth"
                >
                  <!-- 表格 -->

                  <page-table
                    :refresh="maintenanceTableInfo.refresh"
                    :init-curpage="maintenanceTableInfo.initCurpage"
                    v-model:data="maintenanceTableInfo.data"
                    :pager="false"
                    :check-box="false"
                    :tab-index="true"
                    :api="maintenanceTableInfo.api"
                    :query="maintenanceTableInfo.query"
                    :field-list="maintenanceTableInfo.fieldList"
                  >
                    <template v-slot:col-orderNo="scope">
                      <span
                        v-if="$permission('maintenanceOrder:view')"
                        class="slip-edit"
                        @click="showMaintenanceDetail(scope.row)"
                      >
                        {{ scope.row.orderNo || '-' }}
                      </span>
                      <span v-else>
                        {{ scope.row.orderNo || '-' }}
                      </span>
                    </template>
                  </page-table>
                </el-tab-pane>
                <el-tab-pane
                  class="model-panel-title"
                  label="养护记录"
                  name="seventh"
                >
                  <page-table
                    :refresh="curingTableInfo.refresh"
                    :init-curpage="curingTableInfo.initCurpage"
                    v-model:data="curingTableInfo.data"
                    :pager="false"
                    :check-box="false"
                    :tab-index="true"
                    :api="curingTableInfo.api"
                    :query="curingTableInfo.query"
                    :field-list="curingTableInfo.fieldList"
                  >
                    <template v-slot:col-orderNo="scope">
                      <span
                        class="slip-edit"
                        @click="showCuringDetail(scope.row)"
                      >
                        {{ scope.row.orderNo || '-' }}
                      </span>
                    </template>
                  </page-table>
                </el-tab-pane>
                <el-tab-pane
                  class="model-panel-title"
                  label="资产文档"
                  name="eighth"
                >
                  <div style="margin: 10px">
                    <upload-img
                      v-model:value="baseInfoList.data.assetFileUrlList"
                      multiple
                      :action="formInfo.action"
                      title="资产文档"
                      :file-type="formInfo.fileType"
                      :limit="10"
                      :response-fn="handleResponse"
                      :showName="true"
                      @input="upload"
                    />
                  </div>
                </el-tab-pane>
                <el-tab-pane
                  v-if="
                    baseInfoList.data.status === 3 &&
                    baseInfoList.data.isFinanceAsset === 1
                  "
                  class="model-panel-title"
                  label="财务信息明细"
                  name="nine"
                >
                  <page-table
                    :refresh="financialDetailInfo.refresh"
                    :init-curpage="financialDetailInfo.initCurpage"
                    v-model:data="financialDetailInfo.data"
                    :pager="false"
                    :check-box="false"
                    :tab-index="true"
                    :api="financialDetailInfo.api"
                    :query="financialDetailInfo.query"
                    :field-list="financialDetailInfo.fieldList"
                  ></page-table>
                </el-tab-pane>
                <el-tab-pane
                  class="model-panel-title"
                  label="关联卡片"
                  name="ten"
                >
                  <page-table
                    v-model:data="relationCardInfo.data"
                    :pager="false"
                    :check-box="false"
                    row-key="id"
                    :treeProps="{
                      children: 'children',
                      hasChildren: 'hasChildren',
                    }"
                    :tab-index="false"
                    :isGroupSearch="true"
                    :defaultExpandAll="true"
                    :cell-class-name="tableCellClassName"
                    :field-list="relationCardInfo.fieldList"
                    @exChange="exChange"
                  ></page-table>
                </el-tab-pane>
                <el-tab-pane
                  class="model-panel-title"
                  label="关联招标项目"
                  name="eleven"
                >
                  <page-table
                    v-model:data="biddingProjectInfo.data"
                    :pager="false"
                    :check-box="false"
                    :tab-index="true"
                    :field-list="biddingProjectInfo.fieldList"
                  ></page-table>
                </el-tab-pane>
                <el-tab-pane
                  class="model-panel-title"
                  label="设备试用"
                  name="twelve"
                >
                  <page-table
                    v-model:data="trialList.data"
                    :pager="false"
                    :check-box="false"
                    :tab-index="true"
                    :field-list="trialList.fieldList"
                  ></page-table>
                </el-tab-pane>
                <el-tab-pane
                  class="model-panel-title"
                  label="巡检记录"
                  name="thirteen"
                >
                  <page-table
                    v-model:data="recodeList.data"
                    :pager="false"
                    :check-box="false"
                    :tab-index="true"
                    :field-list="recodeList.fieldList"
                  >
                  <template v-slot:col-orderNo="scope">
                      <span
                        class="slip-edit"
                        @click="showRecodeDetail(scope.row)"
                      >
                        {{ scope.row.orderNo || '-' }}
                      </span>
                    </template>
                </page-table>
                </el-tab-pane>
              </el-tabs>
            </div>
          </div>
        </div>

        <chose-printer
          :visible="printerInfo.visible"
          @callBack="handlePrinterCallBack"
        />
      </NewFullScreen>
    </div>
    <asset-modify
      v-if="showModify.visible"
      :id="id"
      v-model:visible="showModify.visible"
      :title="showModify.title"
      :type="showModify.type"
      :isCopy="showModify.isCopy"
      :current-accounting-interval="showModify.currentAccountingInterval"
      @returnModify="modifyCallback"
    ></asset-modify>
    <asset-modify
      v-if="replenishMaintenanceModify.visible"
      :id="id"
      v-model:visible="replenishMaintenanceModify.visible"
      :title="replenishMaintenanceModify.title"
      :current-accounting-interval="
        replenishMaintenanceModify.currentAccountingInterval
      "
      :type="replenishMaintenanceModify.type"
      :canModifyModule="replenishMaintenanceModify.canModifyModule"
      @returnModify="modifyCallback"
    ></asset-modify>
    <!-- 财务信息登记 -->
    <RegisterFinancialInformation
      v-if="financeModifyInfo.visible"
      :id="financeModifyInfo.id"
      v-model:visible="financeModifyInfo.visible"
      :title="financeModifyInfo.title"
      :current-accounting-interval="financeModifyInfo.currentAccountingInterval"
      :canModifyModule="replenishMaintenanceModify.canModifyModule"
      :type="financeModifyInfo.type"
      @returnModify="returnFinanceModifyInfo"
    />
    <maintenanceOrder-detail
      v-if="maintenanceOrderDetailInfo.visible"
      :id="maintenanceOrderDetailInfo.id"
      v-model:visible="maintenanceOrderDetailInfo.visible"
      :title="maintenanceOrderDetailInfo.title"
      @returnBack="modifyCallback"
    />
    <curing-detail
      v-if="curingDetailInfo.visible"
      :id="curingDetailInfo.id"
      v-model:visible="curingDetailInfo.visible"
      @returnBack="modifyCallback"
    />
    <recode-detail
      v-if="recodeDetailInfo.visible"
      :id="recodeDetailInfo.id"
      v-model:visible="recodeDetailInfo.visible"
      @returnBack="modifyCallback"
    />
    <task-detail
      v-if="taskDetailInfo.visible"
      :id="taskDetailInfo.id"
      v-model:visible="taskDetailInfo.visible"
      @returnBack="modifyCallback"
    />
    <assetCardSplit
      v-if="assetCardSplitDialog.visible"
      @callback="modifyCallback"
      v-model:showDialog="assetCardSplitDialog.visible"
      :row="assetCardSplitDialog.row"
    />
  </div>
</template>

<script setup name="assetCardDetails">
import { getMeasuringVerificationRecordPageAll } from '@/api/quality.js'
import associatedSubcard from './component/associatedSubcard.vue'
import assetCardSplit from './component/assetCardSplit.vue'
import {
  getMaintenceOrderAll,
  getDeviceMaintenanceTaskAll,
} from '@/api/repair.js'
import {
  financeCancel,
  financeRatify,
  financeReject,
  financeRevoke,
  financeSubmit,
  getAssetById,
  assetCodePrint,
  submitAssetCardOrder,
  revokeAssetCardOrder,
  ratifyAssetCardOrder,
  cancelAuditAssetCardOrder,
  rejectAssetCardOrder,
  refuseAssetCardOrder,
  getAssetCardPrint,
  exportAssetCardDetail,
  getCurrentFiscalPeriod,
  getAssetCardRelationCard,
} from '@/api/core'
import { orderOpAffairAll } from '@/api/affair'
import { getrecoredByAsset } from '@/api/patrol'
import {
  assetDepreciationAll,
  getAdjustAffairAll,
  getReduceAffairAll,
  getFinancialDetailAll,
  getTrialAll,
} from '@/api/asset'
import {
  fatchTemplateByCode,
  deleteAnnexUpload,
  createAnnexUpload,
} from '@/api/base'
import { getMappingBiddingProjectByAssetIdById } from '@/api/bidding'
import { getCustomizeSetting } from '@/api/customize'
import { doPrint } from '@/utils/exportUtil.js'
import { selectByCodeAndDept } from '@/api/report.js'
import { updatePrintCount } from '@/api/mapping'
const RegisterFinancialInformation = defineAsyncComponent(() =>
  import('@/views/asset/assetManage/assetCard/financeModify')
)
const MaintenanceOrderDetail = defineAsyncComponent(() =>
  import('@/views/repair/repairManage/maintenanceOrder/details.vue')
)
const CuringDetail = defineAsyncComponent(() =>
  import('@/views/repair/repairManage/deviceMaintenanceTask/detail.vue')
)
const recodeDetail = defineAsyncComponent(() =>
  import('@/views/repair/repairManage/patrolRecordRegistration/detail.vue')
)
const taskDetail = defineAsyncComponent(() =>
  import('@/views/repair/repairManage/patrolTask/details.vue')
)
const AssetModify = defineAsyncComponent(() =>
  import('@/views/asset/assetManage/assetCard/modify')
)
const { proxy } = getCurrentInstance()
const emits = defineEmits()
const props = defineProps({
  visible: {
    type: Boolean,
    default: false,
  },
  id: {
    type: [String, Number],
  },
})

const formInfo = ref({
  action: import.meta.env.VITE_APP_BASE_API + '/pub/uploadfile',
  fileType: ['png', 'jpg', 'jpeg', 'pdf', 'doc', 'docx'],
})
const assetCardSplitDialog = ref({
  visible: false,
  row: {},
})
//明细相关
const maintenanceOrderDetailInfo = ref({
  visible: false,
  title: '维修单详情',
  id: '',
})
//明细相关
const curingDetailInfo = ref({
  visible: false,
  id: '',
})
const recodeDetailInfo = ref({
  visible: false,
  id: '',
})
const taskDetailInfo = ref({
  visible: false,
  id: '',
})
const activeName = ref('first')
const title = ref('资产卡片详情')

const printerInfo = ref({
  visible: false,
  data: {},
})
//财务信息修改
const financeModifyInfo = ref({
  visible: false,
  title: '财务信息登记',
  id: '',
  currentAccountingInterval: '',
  type: '',
})
const baseInfoList = ref({
  imageField: {
    label: '资产图片',
    value: 'fileUrlList',
    multipleSheets: false,
  },
  data: [],
  fieldList: [
    {
      label: '资产名称',
      value: 'assetName',
      type: 'text',
    },
    {
      label: '资产卡片号',
      value: 'assetCode',
      type: 'text',
    },
    {
      label: '资产状态',
      value: 'assetStatusValue',
      type: 'text',
    },
    {
      label: '状态值',
      value: 'statusValue',
      type: 'text',
    },
    {
      label: '规格',
      value: 'standard',
      type: 'text',
    },
    {
      label: '厂家名称',
      value: 'brandName',
      type: 'text',
    },
    {
      label: '品牌',
      value: 'mark',
      type: 'text',
    },
    {
      label: '医疗器械分类目录',
      value: 'deviceTypeValue',
      type: 'text',
    },
    {
      label: '医疗器械管理类别',
      value: 'deviceTypeCategoryValue',
      type: 'text',
    },
    {
      label: '临时采购',
      value: 'temporaryPurchValue',
      type: 'text',
    },
    {
      label: '供应商',
      value: 'supplierName',
      type: 'text',
    },
    {
      label: '产地',
      value: 'originPlace',
      type: 'text',
    },

    {
      label: '使用状态',
      value: 'useStatusValue',
      type: 'text',
    },
    // {
    //   label: '计提标志',
    //   value: 'accrualMarkValue',
    //   type: 'text',
    // },
    // {
    //   label: '使用部门',
    //   value: 'useDeptName',
    //   type: 'text',
    //   hidden: false,
    // },
    {
      label: '仓库',
      value: 'depotName',
      type: 'text',
      hidden: true,
    },
    {
      label: '管理部门',
      value: 'manageDeptName',
      type: 'text',
    },
    {
      label: '增加方式',
      value: 'increaseTypeValue',
      type: 'text',
    },
    {
      label: '计量单位',
      value: 'unitName',
      type: 'text',
    },
    {
      label: '数量',
      value: 'qty',
      type: 'text',
    },
    {
      label: '资产单价',
      value: 'price',
      type: 'text',
    },
    {
      label: '安装费',
      value: 'installCost',
      type: 'text',
    },
    {
      label: '运杂费',
      value: 'transportCost',
      type: 'text',
    },
    {
      label: '税费',
      value: 'taxCost',
      type: 'text',
    },
    {
      label: '原值',
      value: 'primitiveOriginalAmount',
      type: 'text',
    },
    {
      label: '资产分类',
      value: 'classifyTypeValue',
      type: 'text',
    },
    {
      label: '资产财务分类',
      value: 'financialClassifyTypeValue',
      type: 'text',
    },
    {
      label: '设备标识',
      value: 'assetMarkValue',
      type: 'text',
    },
    {
      label: '是否为财务资产',
      value: 'isFinanceAssetName',
      type: 'text',
    },
    {
      label: '是否维保',
      value: 'isMaintenanceName',
      type: 'text',
    },
    {
      label: '是否为计量资产',
      value: 'isMeteringName',
      type: 'text',
    },
    {
      label: '是否医疗设备',
      value: 'isMedicalEquipmentValue',
      type: 'text',
    },
    {
      label: '报修预警时长(分钟)',
      value: 'repairWarnTime',
      type: 'text',
    },
    {
      label: '使用部门',
      value: 'assetUseDeptVOList',
      type: 'slot',
      className: 'not-br',
    },
    {
      label: '资金来源',
      value: 'assetCapitalSourceVOList',
      type: 'slot',
      className: 'not-br',
    },
    {
      label: '组件/部件',
      value: 'associatedSubcard',
      type: 'slot',
      className: 'not-br',
    },
    {
      label: '备注',
      value: 'remark',
      type: 'text',
      className: 'not-br',
    },
  ],
})
const commonInfoList = ref({
  data: [],
  fieldList: [
    {
      label: 'SN',
      value: 'machineCode',
      type: 'text',
    },
    {
      label: '注册证号',
      value: 'registerCode',
      type: 'text',
    },
    {
      label: '合同号',
      value: 'contractCode',
      type: 'text',
    },
    {
      label: '档案号',
      value: 'fileCode',
      type: 'text',
    },
    {
      label: '发票编号',
      value: 'invoiceCode',
      type: 'text',
    },
    {
      label: '批号',
      value: 'batchNumber',
      type: 'text',
    },
    {
      label: '出厂日期',
      value: 'manufactureDate',
      type: 'text',
    },
    {
      label: '生产日期',
      value: 'productionDate',
      type: 'text',
    },
    {
      label: '安装日期',
      value: 'installDate',
      type: 'text',
    },
    // {
    //   label: "启用日期",
    //   value: "enableDate",
    //   type: "text",
    // },
    {
      label: '验收人',
      value: 'acceptanceUserName',
      type: 'text',
    },
    {
      label: '验收日期',
      value: 'acceptanceDate',
      type: 'text',
    },
    {
      label: '采购人',
      value: 'purchUserName',
      type: 'text',
    },
    {
      label: '采购日期',
      value: 'purchDate',
      type: 'text',
    },
    {
      label: '入库日期',
      value: 'storeDate',
      type: 'text',
    },
    {
      label: '开始使用日期',
      value: 'useDate',
      type: 'text',
    },
    {
      label: '领用人',
      value: 'applicationUserName',
      type: 'text',
    },
    {
      label: '领用日期',
      value: 'applicationDate',
      type: 'text',
    },
    {
      label: '保管人',
      value: 'keeperUserName',
      type: 'text',
    },
    {
      label: '使用人',
      value: 'useUserName',
      type: 'text',
    },
    {
      label: '责任人',
      value: 'responsibleUserName',
      type: 'text',
    },

    {
      label: '接收人',
      value: 'receiveUserName',
      type: 'text',
    },
    {
      label: '存放地点',
      value: 'location',
      type: 'text',
    },
    {
      label: '预算号',
      value: 'budgetNo',
      type: 'text',
    },
    {
      label: '申购论证号',
      value: 'applicationNo',
      type: 'text',
    },
    {
      label: '合同号',
      value: 'contractNo',
      type: 'text',
    },
    {
      label: '使用年限',
      value: 'useYear',
      type: 'text',
    },
    {
      label: '采购类型',
      value: 'purchTypeValue',
      type: 'text',
    },

  ],
})
const financeInfoList = ref({
  data: [],
  notDeprFieldList: [
    {
      label: '资产类型',
      value: 'assetTypeValue',
      type: 'text',
    },
    // {
    //   label: '财务部门',
    //   value: 'financeDeptName',
    //   type: 'text',
    // },

    {
      label: '原值',
      value: 'originalAmount',
      type: 'text',
    },
    {
      label: '净值',
      value: 'netAmount',
      type: 'text',
    },
    {
      label: '已使用月数',
      value: 'monthsUsed',
      type: 'text',
    },
    {
      label: '折旧方法',
      value: 'deprMethodTypeValue',
      type: 'text',
    },
    // {
    //   label: '进项税',
    //   value: 'inputTax',
    //   type: 'text',
    // },
    {
      label: '入账日期',
      value: 'postingDate',
      type: 'text',
    },
  ],
  fieldList: [
    {
      label: '资产类型',
      value: 'assetTypeValue',
      type: 'text',
    },
    {
      label: '原值',
      value: 'originalAmount',
      type: 'text',
    },
    {
      label: '累计折旧',
      value: 'sumDeprAmount',
      type: 'text',
    },
    {
      label: '净值',
      value: 'netAmount',
      type: 'text',
    },
    {
      label: '折旧月限',
      value: 'deprMonthsLimitValue',
      type: 'text',
    },
    {
      label: '已使用月数',
      value: 'monthsUsedValue',
      type: 'text',
    },
    {
      label: '剩余折旧月数',
      value: 'residueDeprMonths',
      type: 'text',
    },

    // {
    //   label: '残值',
    //   value: 'residualAmount',
    //   type: 'text',
    // },
    // {
    //   label: '残值率(%)',
    //   value: 'residualRate',
    //   type: 'text',
    // },
    {
      label: '减值准备',
      value: 'deprPreparation',
      type: 'text',
    },
    {
      label: '折旧方法',
      value: 'deprMethodTypeValue',
      type: 'text',
    },
    {
      label: '折旧惯例',
      value: 'deprConventionValue',
      type: 'text',
    },
    // {
    //   label: '进项税',
    //   value: 'inputTax',
    //   type: 'text',
    // },
    {
      label: '入账日期',
      value: 'postingDate',
      type: 'text',
    },
    {
      label: '财政资产编码',
      value: 'financialAssetCode',
      type: 'text',
    },
    // {
    //   label: '月折旧率(%)',
    //   value: 'monthDeprRate',
    //   type: 'text',
    // },
    // {
    //   label: '月折旧额',
    //   value: 'monthDeprAmount',
    //   type: 'text',
    // },
  ],
})
const maintenanceInfoList = ref({
  data: [],
  fieldList: [
    {
      label: '保修类型',
      value: 'warrantyTypeValue',
      type: 'text',
    },
    {
      label: '保修状态',
      value: 'warrantyStatusValue',
      type: 'text',
    },
    {
      label: '维保商',
      value: 'maintenanceProviderName',
      type: 'text',
    },
    {
      label: '维保商联系人',
      value: 'maintenanceContactsName',
      type: 'text',
    },
    {
      label: '维保商联系人电话',
      value: 'maintenancePhone',
      type: 'text',
    },
    {
      label: '院内维保人',
      value: 'hospitalMaintainerUserName',
      type: 'text',
    },
    {
      label: '院内维保人电话',
      value: 'hospitalMaintainerPhone',
      type: 'text',
    },
    {
      label: '维保开始日期',
      value: 'warrantyStartDate',
      type: 'text',
    },
    {
      label: '维保结束日期',
      value: 'warrantyEndDate',
      type: 'text',
    },
    {
      label: '维保合同编号',
      value: 'maintenanceContract',
      type: 'text',
    },
    {
      label: '维保说明',
      value: 'maintenanceDescription',
      type: 'text',
    },
    {
      label: '维修状态',
      value: 'repairStatusValue',
      type: 'text',
    },
    {
      label: '报修日期',
      value: 'repairTime',
      type: 'text',
    },
    {
      label: '最近养护日期',
      value: 'maintenanceTime',
      type: 'text',
    },
    {
      label: '最近巡检日期',
      value: 'patrolTime',
      type: 'text',
    },
  ],
})
const measurementInfoList = ref({
  data: [],
  fieldList: [
    {
      label: '标准名称',
      value: 'measurementName',
      type: 'text',
    },
    {
      label: '专业分类',
      value: 'professionalClassificationValue',
      type: 'text',
    },
    {
      label: '是否强检',
      value: 'isMandatoryInspectionValue',
      type: 'text',
    },
    {
      label: '拼音码',
      value: 'pinyinCode',
      type: 'text',
    },
    {
      label: '测量范围',
      value: 'measurementRange',
      type: 'text',
    },
    {
      label: '准确度',
      value: 'accuracy',
      type: 'text',
    },
    {
      label: '检定周期(月)',
      value: 'verificationPeriod',
      type: 'text',
    },
    {
      label: '检定类型',
      value: 'verificationTypeValue',
      type: 'text',
    },
    {
      label: '检定单位',
      value: 'verificationUnit',
      type: 'text',
    },
    {
      label: '上次检定日期',
      value: 'verificationDate',
      type: 'text',
    },
    {
      label: '主要参数',
      value: 'mainParameter',
      type: 'text',
    },
    {
      label: '下次检定日期',
      value: 'validityDate',
      type: 'text',
    },
    {
      label: '最新检定结果',
      value: 'verificationResultValue',
      type: 'text',
    },
    {
      label: '检定证书编号',
      value: 'verificationCertificateNumber',
      type: 'text',
    },

  ],
})
// 折旧记录
const deprTableInfo = ref({
  refresh: 1,
  initCurpage: 1,
  api: assetDepreciationAll,
  data: [],
  query: {
    assetId: props.id,
    sort: 'accounting_time desc',
  },
  fieldList: [
    { label: '会计期间', value: 'fiscalPeriodName' },
    // { label: '业务日期', value: 'businessDate' },
    { label: '资金来源', value: 'capitalSourceName' },
    { label: '使用部门', value: 'useDeptName' },
    // { label: '月折旧率(%)', value: 'monthDeprRate' },
    { label: '月折旧额', value: 'monthDeprAmount' },
    { label: '累计折旧额', value: 'sumDeprAmount' },
    // { label: '计提时间', value: 'accountingTime' },
    { label: '计提人员', value: 'accountingUserName' },
    // { label: '备注', value: 'remark' },
  ],
})
// 调整记录
const adjustTableInfo = ref({
  refresh: 1,
  initCurpage: 1,
  api: getAdjustAffairAll,
  data: [],
  query: {
    assetId: props.id,
    sort: 'operate_time desc',
  },
  fieldList: [
    { label: '调整单号', value: 'orderNo' },
    { label: '单据类型', value: 'orderTypeValue' },
    { label: '调整类型', value: 'adjustTypeValue' },
    { label: '调整前内容', value: 'adjustBeforeValue' },
    { label: '调整后内容', value: 'adjustAfterValue' },
    { label: '调整日期', value: 'operateTime' },
    { label: '调整原因', value: 'adjustReason' },
    { label: '调整人', value: 'operateUserName' },
    { label: '业务日期', value: 'businessDate' },
    { label: '备注', value: 'remark' },
  ],
})
// 减少记录
const reduceTableInfo = ref({
  refresh: 1,
  initCurpage: 1,
  api: getReduceAffairAll,
  data: [],
  query: {
    assetId: props.id,
    sort: 'reduce_time desc',
  },
  fieldList: [
    { label: '单号', value: 'orderNo' },
    { label: '单据类型', value: 'orderTypeValue' },
    { label: '减少人', value: 'reduceUserName' },
    { label: '减少时间', value: 'reduceTime' },
    { label: '减少原因', value: 'reduceReason' },
    { label: '处置收入', value: 'cleanUpIncome' },
    { label: '处置费用', value: 'cleanUpCost' },
    { label: '业务日期', value: 'businessDate' },
    { label: '备注', value: 'remark' },
  ],
})
// 操作流水
const affairTableInfo = ref({
  api: orderOpAffairAll,
  query: {
    orderType: 36,
    orderId: props.id,
    sort: 'operate_time desc',
  },
})
//计量器具检定记录
const instrumentsRecordTableInfo = ref({
  refresh: 1,
  initCurpage: 1,
  data: [],
  api: undefined,
  fieldList: [],
})
const instrumentsRecordFilterInfo = ref({
  query: {
    queryMap: {
      assetId: {
        asTbName: 'asset_instruments_plan',
        columnName: 'assetId',
        queryType: 'EQUALS',
        queryCategory: 'AND',
        value: props.id,
      },
    },
    customizeUserVO: {},
  },
})
const btnList = ref([])
// 维修记录
const maintenanceTableInfo = ref({
  refresh: 1,
  initCurpage: 1,
  api: getMaintenceOrderAll,
  data: [],
  query: {
    assetId: props.id,
    statusMult: '2,3,4',
    // orderId: props.id,
    // sort: "create_time desc",
  },
  fieldList: [
    { label: '维修单号', value: 'orderNo', type: 'slot' },
    { label: '状态', value: 'statusValue' },
    { label: '维修人', value: 'maintenanceUserName' },
    { label: '维修渠道', value: 'maintainChannelName' },
    { label: '故障时间', value: 'faultTime' },
    { label: '故障部位', value: 'faultPart' },
    { label: '故障描述', value: 'faultDescribe' },
    { label: '费用合计', value: 'sumAmount' },
  ],
})
// 养护记录
const curingTableInfo = ref({
  refresh: 1,
  initCurpage: 1,
  api: getDeviceMaintenanceTaskAll,
  data: [],
  query: {
    assetId: props.id,
    statusMult: '2,3',
    // orderId: props.id,
    // sort: "create_time desc",
  },
  fieldList: [
    { label: '养护单号', value: 'orderNo', type: 'slot' },
    { label: '状态', value: 'statusValue' },
    { label: '养护类型', value: 'typeValue' },
    { label: '养护负责人', value: 'maintenancePrincipalValue' },
    { label: '完工日期', value: 'completeDate' },
    { label: '合计工时(h)', value: 'totalHours' },
    { label: '养护服务费', value: 'maintenanceAmount' },
    { label: '养护材料费', value: 'maintenanceMaterialsAmount' },
    { label: '费用合计', value: 'amount' },
  ],
})
// 财务信息记录
const financialDetailInfo = ref({
  refresh: 1,
  initCurpage: 1,
  api: getFinancialDetailAll,
  data: [],
  query: {
    assetId: props.id,
    sort: 'status desc,capital_source_id desc,use_dept_id desc',
  },
  fieldList: [
    { label: '资金来源', value: 'capitalSourceName' },
    { label: '资金来源金额', value: 'capitalSourceAmount' },
    { label: '资金来源比例(%)', value: 'capitalSourceRate' },
    { label: '使用部门', value: 'useDeptName' },
    { label: '使用部门比例(%)', value: 'deptRate' },
    { label: '原值', value: 'originalAmount' },
    // { label: '残值率(%)', value: 'residualRate' },
    // { label: '残值', value: 'residualAmount' },
    { label: '净值', value: 'netAmount' },
    { label: '累计折旧金额', value: 'sumDeprAmount' },
    { label: '减值准备', value: 'deprPreparation' },
    { label: '状态', value: 'statusValue' },
  ],
})
// 财务信息记录
const biddingProjectInfo = ref({
  data: [],
  fieldList: [
    {
      label: '招标编号',
      value: 'biddingNumber',
    },
    { label: '项目名称', value: 'name' },
    { label: '预算金额', value: 'budgetAmount' },
    { label: '开标时间', value: 'openTime' },
    { label: '开标地点', value: 'openAddress' },
    { label: '采购人', value: 'purchUser' },
    { label: '采购联系人', value: 'purchContactUser' },
    { label: '采购联系人电话', value: 'purchContactUserTel' },
    { label: '采购代理机构', value: 'purchAgency' },
    { label: '代理机构联系人', value: 'agencyUser' },
    { label: '代理机构联系人电话', value: 'agencyUserTel' },
    { label: '备注', value: 'remark' },
  ],
})
const trialList = ref({
  data: [],
  fieldList: [
    { label: '试用单号', value: 'orderNo' },
    { label: '试用科室', value: 'deptName' },
    { label: '试用开始日期', value: 'trialStartDate' },
    { label: '试用截止日期', value: 'trialEndDate' },
    { label: '设备名称', value: 'assetName' },
    { label: '规格', value: 'standard' },
    { label: '序列号', value: 'sequenceNo' },
    { label: '注册证号', value: 'registerCode' },
    { label: '生产厂家', value: 'brandName' },
    { label: '生产日期', value: 'productionDate' },
    { label: '供应商', value: 'supplierName' },
    { label: '安装日期', value: 'installDate' },
    { label: '安装地点', value: 'installLocation' },
  ],
})
const recodeList = ref({
  data: [],
  fieldList: [
    { label: '任务编号', value: 'orderNo', type: 'slot' },
    { label: '巡检人', value: 'patrolUserName' },
    { label: '巡检时间', value: 'patrolDate' },
    { label: '巡检项目名称', value: 'patrolTaskItemName;' },
    { label: '巡检结果', value: 'patrolRecoredDetailResult' },
    { label: '正常/异常', value: 'patrolTaskItemResultValue' }
  ],
})
// 关联卡片
const relationCardInfo = ref({
  data: [],
  query: {
    id: props.id,
    sort: 'create_time desc',
  },
  fieldList: [
    {
      label: '资产卡片号',
      value: 'assetCode',
    },
    {
      label: '资产名称',
      value: 'assetName',
    },
    {
      label: '规格',
      value: 'standard',
    },
    {
      label: '厂家',
      value: 'brandName',
    },
    {
      label: '供应商名称',
      value: 'supplierName',
    },
    // {
    //   label: '使用部门',
    //   value: 'useDeptNameRate',
    // },
    {
      label: '管理部门',
      value: 'manageDeptName',
    },
    {
      label: '使用状态',
      value: 'useStatusValue',
    },
  ],
})
// 过滤相关配置
const customFilterInfo = ref({
  query: {
    queryMap: {
      id: {
        queryType: 'EQUALS',
        queryCategory: 'AND',
        value: props.id,
      },
    },
    queryParams: {
      isAssetAchievesExcel: 'true',
    },
  },
})
const showModify = ref({
  title: '修改',
  type: 'update',
  visible: false,
  currentAccountingInterval: '',
})
const replenishMaintenanceModify = ref({
  title: '信息补录',
  type: 'update',
  visible: false,
  currentAccountingInterval: '',
  canModifyModule: 'noFinanceAsset',
})
//资金来源表格
const assetCapitalSourceTableInfo = ref({
  summaryFieldList: [
    { value: 'amount', formatter: proxy.$fn.TripartiteMethod },
  ],
  fieldList: [
    {
      label: '项目类型',
      value: 'sourceName',
    },
    {
      label: '金额',
      value: 'amount',
    },
    {
      label: '资金项目-(使用金额)',
      value: 'capitalProjectList',
      type: 'slot',
    },
  ],
})
//摊销部门表格
const assetAmortizationDeptTableInfo = ref({
  fieldList: [
    {
      label: '使用部门',
      value: 'useDeptName',
    },
    {
      label: '占比(%)',
      value: 'rate',
      labelTip: '总值100%',
    },
  ],
})
const copyAssetFileUrlList = ref([])
const showDialog = computed({
  get() {
    return props.visible
  },
  set(val) {
    // 更新父组件visible
    emits('update:visible', val)
  },
})

const canPrint = computed(() => {
  return (
    proxy.$permission('assetCard:print') && baseInfoList.value.data.status !== 1
  )
})
const canExcel = computed(() => {
  return (
    proxy.$permission('assetCard:excel') && baseInfoList.value.data.status !== 1
  )
})
const canUpdate = computed(() => {
  return [1, 6].includes(baseInfoList.value.data.status)
})
//提交
const canSubmit = computed(() => {
  return (
    proxy.$permission('assetCard:submit') &&
    [1, 6].includes(baseInfoList.value.data.status)
  )
})
//撤回
const canRevoke = computed(() => {
  return (
    proxy.$permission('assetCard:revoke') &&
    (baseInfoList.value.data.status === 2 ||
      (baseInfoList.value.data.status === 3 &&
        Number(
          proxy.$store.state.permission.systemConfig
            .assets_register_approval_type
        ) === 0)) &&
    (baseInfoList.value.data.assetStatus === 1 ||
      baseInfoList.value.data.assetStatus === 3)
  )
})
//批准
const canRatify = computed(() => {
  return (
    proxy.$permission('assetCard:approve') &&
    baseInfoList.value.data.status === 2 &&
    (baseInfoList.value.data.assetStatus === 1 ||
      baseInfoList.value.data.assetStatus === 3) &&
    proxy.$store.state.permission.systemConfig.assets_register_approval_type ==
      1
  )
})
const canCancelAudit = computed(() => {
  return (
    proxy.$permission('assetCard:cancelAudit') &&
    baseInfoList.value.data.status === 3 &&
    baseInfoList.value.data.assetStatus !== 2 &&
    Number(
      proxy.$store.state.permission.systemConfig.assets_register_approval_type
    ) !== 0
  )
})
//驳回
const canReject = computed(() => {
  return (
    proxy.$permission('assetCard:reject') &&
    baseInfoList.value.data.status === 2 &&
    (baseInfoList.value.data.assetStatus === 1 ||
      baseInfoList.value.data.assetStatus === 3) &&
    proxy.$store.state.permission.systemConfig.assets_register_approval_type ==
      1
  )
})
const canRefuse = computed(() => {
  return (
    proxy.$permission('assetCard:refuse') &&
    baseInfoList.value.data.status === 2 &&
    (baseInfoList.value.data.assetStatus === 1 ||
      baseInfoList.value.data.assetStatus === 3) &&
    proxy.$store.state.permission.systemConfig.assets_register_approval_type ==
      1
  )
})
const canSlpit = computed(() => {
  return (
    proxy.$permission('assetCard:splitCard') &&
    baseInfoList.value.data.status === 3 &&
    (baseInfoList.value.data.assetStatus === 1 ||
      baseInfoList.value.data.assetStatus === 3)
  )
})
//补录信息
const canReplenishMaintenance = computed(() => {
  return (
    proxy.$permission('assetCard:replenishMaintenance') &&
    baseInfoList.value.data.status === 3 &&
    baseInfoList.value.data.assetStatus !== 2
  )
})
//打印资产条码
const canPrintAsset = computed(() => {
  return (
    proxy.$permission('assetCard:printAsset') &&
    baseInfoList.value.data.status !== 1 &&
    baseInfoList.value.data.status !== 2
  )
})
const canRegisterFinance = computed(() => {
  return (
    proxy.$permission('assetCard:registerFinancialInformation') &&
    baseInfoList.value.data.status === 3 &&
    (baseInfoList.value.data.assetStatus === 1 ||
      baseInfoList.value.data.assetStatus === 3)
  )
})
const canUpdateFinance = computed(() => {
  return (
    proxy.$permission('assetCard:updateFinancialInformation') &&
    baseInfoList.value.data.status === 4 &&
    (baseInfoList.value.data.assetStatus === 1 ||
      baseInfoList.value.data.assetStatus === 3)
  )
})

const canSubmitFinance = computed(() => {
  return (
    proxy.$permission('assetCard:submitFinancialInformation') &&
    baseInfoList.value.data.status === 4 &&
    (baseInfoList.value.data.assetStatus === 1 ||
      baseInfoList.value.data.assetStatus === 3)
  )
})
const canCancelFinance = computed(() => {
  return (
    proxy.$permission('assetCard:cancelFinancialInformation') &&
    baseInfoList.value.data.status === 4 &&
    (baseInfoList.value.data.assetStatus === 1 ||
      baseInfoList.value.data.assetStatus === 3)
  )
})
const canRatifyFinance = computed(() => {
  return (
    proxy.$permission('assetCard:confirmFinancialInformation') &&
    baseInfoList.value.data.status === 5 &&
    (baseInfoList.value.data.assetStatus === 1 ||
      baseInfoList.value.data.assetStatus === 3)
  )
})
const canRejectFinance = computed(() => {
  return (
    proxy.$permission('assetCard:rejectFinancialInformation') &&
    baseInfoList.value.data.status === 5 &&
    (baseInfoList.value.data.assetStatus === 1 ||
      baseInfoList.value.data.assetStatus === 3)
  )
})
const canRevokeFinance = computed(() => {
  return (
    proxy.$permission('assetCard:revokeFinancialInformation') &&
    baseInfoList.value.data.status === 5 &&
    (baseInfoList.value.data.assetStatus === 1 ||
      baseInfoList.value.data.assetStatus === 3)
  )
})
const canFinanceAdjust = computed(() => {
  return (
    proxy.$permission('assetCard:financeAdjust') &&
    baseInfoList.value.data.status === 3 &&
    (baseInfoList.value.data.assetStatus === 1 ||
      baseInfoList.value.data.assetStatus === 3) &&
    baseInfoList.value.data.isCurrentMonth
  )
})
const canCopyCreate = computed(() => {
  return (
    proxy.$permission('assetCard:copyCreate') &&
    [1, 3].includes(baseInfoList.value.data.status) &&
    [1, 2].includes(baseInfoList.value.data.useStatus) &&
    baseInfoList.value.data.assetStatus !== 2

  )
})

getDetails()
getCustomize()

function showFieldListItem(show, nameValue) {
  let fieldList = baseInfoList.value.fieldList
  fieldList.forEach((item) => {
    if (nameValue === item.value) {
      item.show = show
    }
  })
}
function copyCreate() {
  //复制并新增
  getCurrentFiscalPeriod(2).then((resp) => {
    if (resp && resp.success && resp.data) {
      showModify.value.currentAccountingInterval = resp.data.startDate
    } else {
      proxy.$message({
        type: 'error',
        duration: 3500,
        message: '未开启会计期间，请先开启会计期间!',
        showClose: true,
      })
    }
    showModify.value.type = 'create'
    showModify.value.id = baseInfoList.value.data.id
    showModify.value.visible = true
    showModify.value.isCopy = true
    showModify.value.title = '新增资产卡片'
    showModify.value.canModifyModule = ''
    showModify.value.buildCardData = []
  })
}

function upload(data, index) {
  if (Object.prototype.toString.call(data) === '[object Array]') {
    if (index >= 0) {
      //删除
      let params = copyAssetFileUrlList.value
      deleteAnnexUpload(params[index].id).then((res) => {
        if (res.success) {
          getDetails()
        }
      })
    } else {
      //新增
      baseInfoList.value.data.assetFileUrlList.forEach((item) => {
        item.annexCategory = 2
        item.annexSubCategory = 2
        item.relativeId = props.id
        item.orgId = proxy.$store.state.user.userInfo.user
          ? proxy.$store.state.user.userInfo.user.orgId
          : ''
      })
      let obj =
        baseInfoList.value.data.assetFileUrlList[
          baseInfoList.value.data.assetFileUrlList.length - 1
        ]
      console.log(obj, 'obj')
      createAnnexUpload(obj).then((res) => {
        if (res.success) {
          getDetails()
        }
      })
    }
  }
}
function handleResponse(response, file) {
  return file
}
function showCuringDetail(row) {
  //跳转维修单详情
  curingDetailInfo.value.visible = true
  curingDetailInfo.value.id = row.id
}
function showRecodeDetail(row) {
  if(row.patrolDetailType === 'patrolRecoredDetail') {
    recodeDetailInfo.value.visible = true
    recodeDetailInfo.value.id = row.recoredId
  } else {
    taskDetailInfo.value.visible = true
    taskDetailInfo.value.id = row.recoredId
  }
}
function showMaintenanceDetail(row) {
  //跳转维修单详情
  maintenanceOrderDetailInfo.value.visible = true
  maintenanceOrderDetailInfo.value.id = row.id
}
function getInstrumentsRecordCustomize() {
  let obj = {
    assetName: {
      label: '资产名称',
      value: 'assetName',
      componentType: 'input',
      show: false,
      hidden: true,
    },
    isMandatoryInspection: {
      label: '是否强检',
      value: 'isMandatoryInspection',
      componentType: 'select-model',
      code: 'yes_or_no',
      show: false,
      hidden: true,
    },
    useStatus: {
      label: '使用状态',
      value: 'useStatus',
      componentType: 'select-model',
      code: 'asset_font_status',
      show: false,
      hidden: true,
    },
    preVerificationDate: {
      label: '上次检定日期',
      value: 'preVerificationDate',
      componentType: 'date',
      show: false,
      hidden: true,
    },
    preVerificationPeriod: {
      label: '检定周期',
      value: 'preVerificationPeriod',
      componentType: 'number',
      show: true,
      hidden: true,
    },
    checkDatePlan: {
      label: '计划检定日期',
      value: 'checkDatePlan',
      componentType: 'date',
      show: false,
      hidden: true,
    },
  }
  instrumentsRecordTableInfo.value.fieldList = Object.values({
    ...proxy.$fn.deepClone(proxy.$fieldfList.FieldList),
    ...proxy.$fn.deepClone(obj),
  })
  let param = {
    tableKey:
      'measuringVerificationRecordList-com.slip.spd.entity.vo.quality.MeasuringVerificationRecordVO',
  }
  getCustomizeSetting(param).then((res) => {
    if (res && res.success) {
      let data = res.data
      instrumentsRecordFilterInfo.value.query.customizeUserVO = data
      let tableFieldInfo = proxy.$fn.setFieldList(
        instrumentsRecordTableInfo.value.fieldList,
        data.detail,
        true
      )
      instrumentsRecordTableInfo.value.fieldList = tableFieldInfo.fieldList
      instrumentsRecordTableInfo.value.api =
        getMeasuringVerificationRecordPageAll
      getInstrumentsRecordList()
    }
  })
}
function handleClick(tab) {
  const name = tab.paneName
  if (name == 'first') {
    getDepreciationList()
  } else if (name == 'second') {
    getAdjustList()
  } else if (name == 'third') {
    getReduceList()
  } else if (name == 'five') {
    getInstrumentsRecordCustomize()
  } else if (name == 'sixth') {
    getMaintenanceList()
  } else if (name == 'seventh') {
    getCuringList()
  } else if (name == 'nine') {
    getFinancialDetail()
  } else if (name == 'ten') {
    getAssetCardRelationCardList()
  } else if (name == 'eleven') {
    getBiddingProject()
  } else if (name == 'twelve') {
    _getTrialAll()
  } else if (name == 'thirteen') {
    _getRecodeAll()
  }
}
//财务信息确认
function ratifyFinance() {
  const data = []
  data.push(baseInfoList.value.data.id)
  financeRatify(data).then((resp) => {
    if (resp && resp.success) {
      getDetails()
    }
  })
}
//财务信息取消
function cancelFinancialInformation() {
  const data = []
  data.push(baseInfoList.value.data.id)
  financeCancel(data).then((resp) => {
    if (resp && resp.success) {
      getDetails()
    }
  })
}
function updateFinance() {
  getCurrentFiscalPeriod(2).then((resp) => {
    if (resp && resp.success && resp.data) {
      financeModifyInfo.value.visible = true
      financeModifyInfo.value.id = baseInfoList.value.data.id
      financeModifyInfo.value.currentAccountingInterval = resp.data.startDate
      financeModifyInfo.value.type = 'update'
    } else {
      proxy.$message({
        type: 'error',
        duration: 3500,
        message: '未开启会计期间，请先开启会计期间!',
        showClose: true,
      })
    }
  })
}

//财务信息提交
function submitFinance() {
  const data = []
  data.push(baseInfoList.value.data.id)
  financeSubmit(data).then((resp) => {
    if (resp && resp.success) {
      getDetails()
    }
  })
}
//财务信息驳回
function rejectFinance() {
  proxy
    .$prompt('请输入驳回理由', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
    })
    .then(({ value }) => {
      const data = {
        id: baseInfoList.value.data.id,
        rejectReason: value,
      }
      financeReject(data).then((resp) => {
        if (resp && resp.success) {
          getDetails()
        }
      })
    })
}
//财务信息撤销
function revokeFinance() {
  const data = []
  data.push(baseInfoList.value.data.id)
  financeRevoke(data).then((resp) => {
    if (resp && resp.success) {
      getDetails()
    }
  })
}
//维保信息补录
function replenishMaintenance() {
  //获取会计区间
  getCurrentFiscalPeriod(2).then((resp) => {
    if (resp && resp.success && resp.data) {
      replenishMaintenanceModify.value.visible = true
      replenishMaintenanceModify.value.currentAccountingInterval =
        resp.data.startDate
    } else {
      proxy.$message({
        type: 'error',
        duration: 3500,
        message: '未开启会计期间，请先开启会计期间!',
        showClose: true,
      })
    }
  })
}
function modifyCallback() {
  getDetails()
  handleClick({
    paneName: activeName.value,
  })
}
function returnFinanceModifyInfo() {
  getDetails()
  handleClick({
    paneName: activeName.value,
  })
}
function showFinanceFieldListItem(show, nameValue) {
  let fieldList = financeInfoList.value.fieldList
  fieldList.forEach((item) => {
    if (nameValue === item.value) {
      item.show = show
    }
  })
}
function printAssetCode() {
  const data = []
  data.push(baseInfoList.value.data.id)
  assetCodePrint(data).then((res) => {
    if (res && res.success) {
      printerInfo.value.visible = true
      printerInfo.value.data = res.data
    }
  })
}
function submit() {
  let data = {
    flowTaskCommentDto: { approvalType: 'submit' },
    processDefinitionKey: 'assetCard',
    orderIds: [baseInfoList.value.data.id],
  }
  submitAssetCardOrder(data).then((resp) => {
    if (resp && resp.success) {
      getDetails()
    }
  })
}
function tableCellClassName({ column, row }) {
  if (row.id === baseInfoList.value.data.id) {
    return 'success-row'
  } else {
    return ''
  }
}
function revoke() {
  const data = []
  data.push(baseInfoList.value.data.id)
  revokeAssetCardOrder(data).then((resp) => {
    if (resp && resp.success) {
      if (proxy.$route.query.processInstanceId) {
        proxy.$fn.setFlowPath(proxy)
        return
      }
      getDetails()
    }
  })
}
function ratify() {
  const data = []
  data.push(baseInfoList.value.data.id)
  ratifyAssetCardOrder(data).then((resp) => {
    if (resp && resp.success) {
      getDetails()
    }
  })
}
function cancelAudit() {
  const data = []
  data.push(baseInfoList.value.data.id)
  cancelAuditAssetCardOrder(data).then((resp) => {
    if (resp && resp.success) {
      if (proxy.$route.query.processInstanceId) {
        proxy.$fn.setFlowPath(proxy)
        return
      }
      getDetails()
    }
  })
}
//驳回
function reject() {
  proxy
    .$prompt('请输入驳回理由', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
    })
    .then(({ value }) => {
      const data = {
        id: baseInfoList.value.data.id,
        checkOpt: value,
      }
      rejectAssetCardOrder(data).then((resp) => {
        if (resp && resp.success) {
          getDetails()
        }
      })
    })
}
//拒绝
function refuse() {
  proxy
    .$prompt('请输入拒绝理由', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
    })
    .then(({ value }) => {
      const data = {
        id: baseInfoList.value.data.id,
        checkOpt: value,
      }
      refuseAssetCardOrder(data).then((resp) => {
        if (resp && resp.success) {
          getDetails()
        }
      })
    })
}
function _assetCardSplit() {
  assetCardSplitDialog.value.visible = true
  assetCardSplitDialog.value.row = baseInfoList.value.data
}
function exportExcel() {
  exportAssetCardDetail(customFilterInfo.value.query).then((resp) => {
    if (resp) {
      proxy.$fn.parseExcel(resp)
    }
  })
}

const templateArr = ref([])
const popoverVisible = ref(false)
//打印
function print() {
  selectByCodeAndDept({
    tempCode: 'assetCardDetail',
    deptId: baseInfoList.value.data.deptId,
  }).then((res) => {
    if (res && res.success) {
      templateArr.value = res.data
      popoverVisible.value = true
      // 一条数据则直接打印
      if (templateArr.value.length === 1) {
        proxy.$refs.popoverShow.hidePopover()
        doPrint({
          name: templateArr.value[0].ureportName,
          params: {
            id: baseInfoList.value.data.id,
          },
          callback: printCallback,
          data: {},
        })
      }
    }
  })
}
function tempClick(item) {
  doPrint({
    name: item.ureportName,
    params: {
      id: baseInfoList.value.data.id,
    },
    callback: printCallback,
    data: {},
  })
  popoverVisible.value = false
}
function printCallback() {}
function update() {
  //获取会计区间
  getCurrentFiscalPeriod(2).then((resp) => {
    if (resp && resp.success && resp.data) {
      showModify.value.visible = true
      showModify.value.isCopy = false
      showModify.value.currentAccountingInterval = resp.data.startDate
    } else {
      proxy.$message({
        type: 'error',
        duration: 3500,
        message: '未开启会计期间，请先开启会计期间!',
        showClose: true,
      })
    }
  })
}

function handlePrinterCallBack(printer) {
  if (printer !== false) {
    proxy.$print.buildRenderBarCode(printerInfo.value.data, printer)
  }
  printerInfo.value.visible = false
}
function returnBack() {
  proxy.$emit('returnBack', false)
}
function financeAdjust() {
  //财务信息调整
  getCurrentFiscalPeriod(2).then((resp) => {
    if (resp && resp.success && resp.data) {
      financeModifyInfo.value.visible = true
      financeModifyInfo.value.id = baseInfoList.value.data.id
      financeModifyInfo.value.currentAccountingInterval = resp.data.startDate
      financeModifyInfo.value.type = 'financeAdjust'
    } else {
      proxy.$message({
        type: 'error',
        duration: 3500,
        message: '未开启会计期间，请先开启会计期间!',
        showClose: true,
      })
    }
  })
}
//财务信息登记
function registerFinancialInformation() {
  getCurrentFiscalPeriod(2).then((resp) => {
    if (resp && resp.success && resp.data) {
      financeModifyInfo.value.visible = true
      financeModifyInfo.value.id = baseInfoList.value.data.id
      financeModifyInfo.value.currentAccountingInterval = resp.data.startDate
      financeModifyInfo.value.type = 'financeRegister'
    } else {
      proxy.$message({
        type: 'error',
        duration: 3500,
        message: '未开启会计期间，请先开启会计期间!',
        showClose: true,
      })
    }
  })
}
function getInstrumentsRecordList() {
  instrumentsRecordTableInfo.value.refresh = Math.random()
}
function getDepreciationList() {
  assetDepreciationAll(deprTableInfo.value.query).then((resp) => {
    if (resp && resp.success && resp.data) {
      deprTableInfo.value.data = resp.data
    }
  })
}

function getAdjustList() {
  adjustTableInfo.value.refresh = Math.random()
}
function getReduceList() {
  reduceTableInfo.value.refresh = Math.random()
}
function getMaintenanceList() {
  maintenanceTableInfo.value.refresh = Math.random()
}
function getCuringList() {
  curingTableInfo.value.refresh = Math.random()
}
function getFinancialDetail() {
  financialDetailInfo.value.refresh = Math.random()
}
function getBiddingProject() {
  getMappingBiddingProjectByAssetIdById(props.id).then((res) => {
    if (res && res.success) {
      biddingProjectInfo.value.data = res.data
    }
  })
}
function _getTrialAll() {
  getTrialAll({ assetClassifyId: baseInfoList.value.data.classifyType }).then(
    (res) => {
      if (res && res.success) {
        trialList.value.data = res.data
      }
    }
  )
}
function _getRecodeAll() {
  getrecoredByAsset(baseInfoList.value.data.id).then(
    (res) => {
      if (res && res.success) {
        recodeList.value.data = res.data
      }
    }
  )
}
function getAssetCardRelationCardList() {
  getAssetCardRelationCard(relationCardInfo.value.query).then((res) => {
    if (res && res.success) {
      relationCardInfo.value.data = res.data
    }
  })
}
function getDetails() {
  console.log(props.id)
  getAssetById(props.id).then((resp) => {
    if (resp && resp.success) {
      baseInfoList.value.data = resp.data
      commonInfoList.value.data = resp.data
      financeInfoList.value.data = resp.data
      maintenanceInfoList.value.data = resp.data
      measurementInfoList.value.data = resp.data
      baseInfoList.value.data.assetFileUrlList =
        resp.data.assetFileUrlList || []
      baseInfoList.value.data.assetResourceVOList =
        resp.data.assetResourceVOList || []
      if (
        baseInfoList.value.data.assetFileUrlList &&
        baseInfoList.value.data.assetFileUrlList.length
      ) {
        copyAssetFileUrlList.value = proxy.$fn.deepClone(
          baseInfoList.value.data.assetFileUrlList
        )
      }
      if (baseInfoList.value.data.depotName) {
        showFieldListItem(true, 'depotName')
        showFieldListItem(false, 'useDeptName')
      } else if (baseInfoList.value.data.useDeptName) {
        showFieldListItem(false, 'depotName')
        showFieldListItem(true, 'useDeptName')
      }
      activeName.value = baseInfoList.value.data.isFinanceAsset
        ? activeName.value
        : activeName.value !== 'first'
        ? activeName.value
        : 'second'
      if (baseInfoList.value.data.isFinanceAsset) {
        getDepreciationList()
      } else {
        getAdjustList()
      }
    }
  })
}
function getCustomize() {
  let param = {
    tableKey: 'coreAssetCardDetail-com.slip.spd.entity.vo.core.CoreAssetVO',
  }
  getCustomizeSetting(param).then((res) => {
    if (res && res.success) {
      let data = res.data
      customFilterInfo.value.query.customizeUserVO = data
    }
  })
}
function exChange() {}
</script>
<style scoped lang="scss">
.el-tabs__header {
  padding: 0 2px !important;
  box-sizing: border-box;
}

.el-tabs__nav-wrap::after {
  height: 1px !important;
}

.asset-card-details {
  :deep(.page-table) {
    width: 100%;
  }
}
.associated-subcard {
  padding-top: 10px;
}
:deep(.el-upload-list){
  width: 158px;
  height: 172px;
}
:deep(.ele-gallery .el-upload-list--picture-card .el-upload-list__item){
  height: 150px
}
</style>
